<div id="blog">
<div class="posts" id="posts">
<?php 
$siteid = $site['id'];
$postsqry = dbSelect('posts',array("site_id=$siteid","parent_id=0","type_id=1 or type_id=2 or type_id=7"),"ORDER BY publishdate DESC");
if(mysql_numrows($postsqry) > 0){ 
$postcnt = 0;
	while($posts = mysql_fetch_array($postsqry)){
		$userid = $posts['author_id'];
		$author = mysql_fetch_array(dbSelect('users',array("id=$userid")));
		$authorname = $author['firstname'].' '.$author['lastname'];
		$nicetime = nicetime($posts['publishdate']);
?>
	<div class="post">
		<?php	if($posts['type_id']==1){ ?>
		<div id="post_body">
			<span id="post_author"><?php echo $authorname; ?></span>
			&nbsp;<?php echo urldecode($posts['post']); ?><br />
			<span id="post_datetime"><?php if($nicetime){echo $nicetime;} ?></span>
		</div>
		<div class="comments">
			<?php 
			$commentsparentid = $posts['id'];
			$commentsqry = dbSelect('posts',array("site_id=$siteid","parent_id=$commentsparentid"));
			if(mysql_numrows($commentsqry) > 0){
				while($comments = mysql_fetch_array($commentsqry)){
					$userid = $comments['author_id'];
					$commentsauthor = mysql_fetch_array(dbSelect('users',array("id=$userid")));
					$commentsauthorname = $commentsauthor['firstname'].' '.$commentsauthor['lastname'];
					$commentsnicetime = nicetime($comments['publishdate']);
			?>
					<div class="comment rounded_comments">
						<div id="comment_body">
							<span id="comment_author"><?php echo $commentsauthorname; ?></span>&nbsp;<?php echo urldecode($comments['post']); ?><br />
							<span id="comment_datetime"><?php echo $commentsnicetime; ?></span>
						</div>
					</div>
			<?php
				} /* /while comments */
			}  /* /if comments */
			?>
		</div><!--/comments-->
		<?php }elseif($posts['type_id']==2){ ?>
<!---EVENTS---------------------------------------------------------------------------------->
		<div class="event_date" style="font-size: small; color: #303030; font-weight: bold; margin-left: 0px;"><?php echo date('F j, Y',dateformat($posts['startdate'])); ?>
				<!---times--->
					&nbsp;&nbsp;&nbsp;<?php echo $posts['starttime']; ?><?php if($posts['endtime']!=""){echo ' - '.$posts['endtime'];} ?>
				<!---times--->
			<div class="event_title rounded_lightblue" style="font-size: 16pt; color: #00137F;"><?php echo urldecode($posts['title']); ?>
				<div class="event_details" style="font-size: small; font-weight: normal; color: #303030;">
					<?php if($posts['event_type'] > 0){
					$eventtypeid = $posts['event_type'];
					$eventtype_qry = dbSelect('ddl_event_type',array("id=$eventtypeid"));
					if(mysql_numrows($eventtype_qry) > 0){
						$eventtypearr = mysql_fetch_array($eventtype_qry);
						$event_type = $eventtypearr['type'];
					}
					echo $event_type;}else{echo 'an event';} ?> 
					<?php if($posts['event_agegroup'] > 0){
					$eventagegroupid = $posts['event_agegroup'];
					$eventagegroup_qry = dbSelect('ddl_agegroup',array("id=$eventagegroupid"));
					if(mysql_numrows($eventagegroup_qry) > 0){
						$eventagegrouparr = mysql_fetch_array($eventagegroup_qry);
						$event_agegroup = $eventagegrouparr['agegroup'];
					}
					echo ' for '.$event_agegroup;}else{echo ' for all ages';} ?>
					<?php if($posts['event_isonsite']==1){ 
					echo 'at '.$site['name'];
						echo '&nbsp;<a title="via Google" class="fakelink" href="http://maps.google.com/?q='.urlencode($site['address']).' '.urlencode($site['address2']).' '.urlencode($site['city']).', '.urlencode($site['state']).' '.urlencode($site['zip']).'" target="_blank">map</a>'; 
					}else{
						echo 'at '.$posts['event_addr'].' '.$posts['event_addr2'].' '.$posts['event_city'].', '.$posts['event_state'].' '.$posts['event_zip'];
						echo '&nbsp;<a title="via Google"  class="fakelink" href="http://maps.google.com/?q='.urlencode($posts['event_addr']).' '.urlencode($posts['event_addr2']).' '.urlencode($posts['event_city']).', '.urlencode($posts['event_state']).' '.urlencode($posts['event_zip']).'" target="_blank">map</a>'; 
					} ?>
					<br />
					<span class="fakelink" onclick="$('#moreinfo_<?php echo $postcnt; ?>').toggle(); $('#rsvp_<?php echo $postcnt; ?>').hide(); $('#providecare_<?php echo $postcnt; ?>').hide();">more info</span>
					&nbsp;<span class="fakelink" onclick="$('#rsvp_<?php echo $postcnt; ?>').toggle(); $('#moreinfo_<?php echo $postcnt; ?>').hide(); $('#providecare_<?php echo $postcnt; ?>').hide();">rsvp</span>
					&nbsp;<span class="fakelink" onclick="$('#providecare_<?php echo $postcnt; ?>').toggle(); $('#moreinfo_<?php echo $postcnt; ?>').hide(); $('#rsvp_<?php echo $postcnt; ?>').hide();">provide care</span>
					&nbsp;<span class="fakelink" onclick="">edit</span>
					&nbsp;<span class="fakelink" onclick="">delete</span>
				<div class="moreinfo" id="moreinfo_<?php echo $postcnt; ?>" style="display: none;"><br />
					<h3>More Information</h3>
					<!---event cost/per--->
					<span class=""><?php echo '$'.$posts['event_cost']; ?></span>
					<?php 
					if($posts['event_per'] > 0){
						$eventperid = $posts['event_per'];
						$eventper_qry = dbSelect('ddl_event_per',array("id=$eventperid"));
						if(mysql_numrows($eventper_qry) > 0){
							$eventperarr = mysql_fetch_array($eventper_qry);
							$event_per = $eventperarr['per'];
						}
						echo $event_per;
					}else{
						echo 'per person';
					} 
					?>
					<!---/event cost/per--->
					<!---event child cost/per--->
						<?php if($posts['event_ischildcare']){echo '<br /><span class="">$'.$posts['childcare_cost'].'</span>'; ?>
						<?php if($posts['cc_per'] > 0){
						$eventccperid = $posts['cc_per'];
						$eventccper_qry = dbSelect('ddl_cc_per',array("id=$eventccperid"));
						if(mysql_numrows($eventccper_qry) > 0){
							$eventccperarr = mysql_fetch_array($eventccper_qry);
							$event_ccper = $eventccperarr['cc_per'];
						}
						echo $event_ccper;}else{echo 'per child';}
						echo '<span class="green" style="font-weight: bold;"> in event</span>';
						} ?>
					<!---/event child cost/per--->
					<!---childcare cost/per--->
					<?php if($posts['event_ischildcare']){echo '<br /><span class="">$'.$posts['childcare_cost'].'</span>'; ?>
					<?php if($posts['cc_per'] > 0){
					$eventccperid = $posts['cc_per'];
					$eventccper_qry = dbSelect('ddl_cc_per',array("id=$eventccperid"));
					if(mysql_numrows($eventccper_qry) > 0){
						$eventccperarr = mysql_fetch_array($eventccper_qry);
						$event_ccper = $eventccperarr['cc_per'];
					}
					echo $event_ccper;}else{echo 'per child';}
					echo '<span class="green" style="font-weight: bold;"> for childcare</span>';
					}else{echo '<span class="red">No childcare available.</span>';} ?><br />
					<!---/childcare cost/per--->
					<!---event desc--->
					<?php echo '<br /><strong>Description:</strong> '.$posts['post']; ?>
					<br />would you like to <span class="fakelink" onclick="$('#moreinfo_<?php echo $postcnt; ?>').toggle(); $('#rsvp_<?php echo $postcnt; ?>').toggle();">rsvp for this?</span>
					<!---/event desc--->
				</div>
				<div class="rsvp" id="rsvp_<?php echo $postcnt; ?>" style="display: none;">
					<br />
					<h3>RSVP</h3>
					this is an RSVP...
				</div>
				<div class="providecare" id="providecare_<?php echo $postcnt; ?>" style="display: none;">
					<br />
					<h3>Provide Care</h3>
					this is providing care...
				</div>
				</div>
			</div>
		</div>
	<!---
		<div id="post_body">
			<span id="post_author" ><?php echo date('F j, Y',dateformat($posts['startdate'])); ?></span>
			&nbsp;<?php echo urldecode($posts['post']); ?><br />
			<span id="post_datetime"><?php if($nicetime){echo $nicetime;} ?></span>
		</div>
		--->
		<!---where comments would go--->
		<?php } ?>
		</div><!--/post-->
<?php
	$postcnt++;
	} /* /while posts */
} /* /if posts */
?>
</div><!--/posts-->
</div><!--/blog-->